package com.yao.shop.mapper;

import com.yao.shop.common.Page;
import com.yao.shop.pojo.ShopProduct;
import com.yao.shop.pojo.vo.ShopProductVo;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface ShopProductMapper {
    void save(ShopProduct shopProduct);

    List<ShopProduct> getByPage(Page<ShopProductVo> page);

    Integer countByPage(Page<ShopProductVo> page);

    ShopProduct getById(Long id);


    /**
     * 修改
     *
     * @param shopProduct
     */
    void update(ShopProduct shopProduct);

    /**
     * 删除
     *
     * @param id
     */
    void delete(Long id);

    /**
     * 更新上架状态
     *
     * @param product
     */
    void updatePublish(ShopProduct product);

    /**
     * 更新新品状态
     *
     * @param product
     */
    void updateNewStatus(ShopProduct product);

    /**
     * 更新推荐状态
     *
     * @param product
     */
    void updateRecommend(ShopProduct product);

    /**
     * 根据id集合查询
     * @param productIds
     * @return
     */
    List<ShopProduct> getByIds(List<Long> productIds);

    /**
     * 分页查询不存在套装的商品
     * @param page
     * @return
     */
    List<ShopProduct> getByPageHasNotPack(Page<ShopProductVo> page);

    /**
     * 查询没有套装的商品总数
     * @param page
     * @return
     */
    Integer countByPageHasNotPack(Page<ShopProductVo> page);

    /**
     * 查询新品商品
     * @return
     */
    List<ShopProduct> getNewProduct();

    /**
     * 查询推荐商品
     * @return
     */
    List<ShopProduct> getRecommendList();

    /**
     * 根据ID查询基本信息
     * @param productId
     * @return
     */
    ShopProduct getInfoById(Long productId);

    /**
     * 查询所在类目下销量最高的6条数据
     * @param categoryId
     * @return
     */
    List<ShopProduct> getRankByCategory(Long categoryId);

    /**
     * 扣减库存
     * @param product
     */
    void updateStock(ShopProduct product);
}
